#ifndef QIPAN_H
#define QIPAN_H

#include<QWidget>
#include<QPaintEvent>
#include<QPainter>
#include <QVector>
#include <QPair>
#include "stdshared.h"

class qipan : public QWidget
{
    Q_OBJECT
public:
    explicit qipan(QWidget *parent = nullptr);
public:
    //记录棋盘位置对应的玩家
    void setBoardInfo(int row, int col, Role role);
    //得到棋盘的信息
    Role ** getBoardInfo(int &boardSize);

    //获取棋盘尺寸
    int getBoardSize();

    //清空棋盘
    void clearBoard();
protected:
    //绘画事件
    void paintEvent(QPaintEvent *event);
    //鼠标移动事件
    void mouseMoveEvent(QMouseEvent *event);
    //鼠标点击事件
    void mousePressEvent(QMouseEvent *event);
signals:
    //发送落子信号
    void ChessClick(int row, int col);

private:
    static const int m_boardSize = 15;
    static const int m_cellSize = 40;
    static const int m_margin = m_cellSize / 2;

    //玩家是1 人机是2
    Role **m_board;

    //悬停坐标
    int m_hoverRow;
    int m_hoverCol;

    bool m_hoverFlag;
};

#endif // QIPAN_H
